#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

void func(){
    vector<int> weight = {1, 3, 4};
    vector<int> value = {15, 20, 30};
    int bagWeight = 4;

    vector<int> dp(bagWeight + 1, 0);

    for(int i = 0; i < bagWeight; i++){
        for(int j = bagWeight; j >= weight[i]; j--){
            dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
        }
    }
    cout << dp[bagWeight] <<endl;
}

int main(){
    func();
}